import { DbService } from '@app/db';
import { PlatformData } from '@app/db/common/entities/PlatformData';
import { Body, Controller, Get, Put } from '@nestjs/common';
import { BaseController } from '../../base/base.controller';

@Controller('platform/setting')
export class PlatformController extends BaseController{
    constructor(
        private readonly db:DbService
    ){
        super()
    }

    @Get('data')
    async getData() {
        const data = await this.db.platformData.queryData()
        return this.successRes(data)
    }

    @Get('data/staticUrl')
    async staticUrl() {
        const data = await this.db.platformData.queryData(['staticUrl'])
        return this.successRes(data.staticUrl)
    }

    @Get('data/deviceQr')
    async deviceQr() {
        const data = await this.db.platformData.queryData(['deviceQr'])
        return this.successRes(data.deviceQr)
    }

    @Put('data/update')
    async updateData(@Body() dto:PlatformData) {
        this.db.platformData.updateData(dto)
        return this.successRes()
    }
}
